package com.tgy.crud.service.impl;

import com.tgy.crud.domain.User;
import com.tgy.crud.service.SendMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SendMessageServiceImpl implements SendMessageService {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void sendEmail(User user) {

      log.info("发送邮件");
    }

    @Override
    public void sendMessage(User user) {

        log.info("发送短信");
    }

    @Async
    @Override
    public void sendAMQPMessage(String exchange, String routingKey, Object object) {

        rabbitTemplate.convertAndSend(exchange,routingKey,object);
    }
}
